const express = require('express');
const { ApolloServer } = require('apollo-server-express');
const mongoose = require('mongoose');
const typeDefs = require('./typeDefs/index');
const resolvers = require('./resolvers/index')
mongoose.connect('mongodb://127.0.0.1:27017/user');
const app = express();
(async () => {
    const server = new ApolloServer({ typeDefs, resolvers,context({req}){
        return {
            token:req.headers.token
        }
    }})
    await server.start();
    server.applyMiddleware({ app })
    app.use((req, res) => {
        res.status(200).end('hhhhh')
    })
    app.listen(4000, () => {
        console.log('app is running')
    })

})()

